package com.rong.tools.service.impl;

import com.rong.tools.mappers.CategoryMapper;
import com.rong.tools.entity.pojo.Category;
import com.rong.tools.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 周厚荣
 * @date 2025/4/20 23:22
 */
@Service
public class CategoryServiceImpl implements CategoryService {
    @Autowired
    private CategoryMapper categoryMapper;

    @Override
    public List<Category> getAllCategories() {
        List<Category> categories = categoryMapper.selectAllCategories();
        return categories;
    }

    @Override
    public Category getCategoryById(Integer id) {
        Category category = categoryMapper.selectCategoryById(id);
        return category;
    }

    @Override
    public boolean addCategory(Category category) {
        return categoryMapper.insertCategory(category) > 0;
    }

    @Override
    public boolean updateCategory(Category category) {
//        System.out.println(category);
        return categoryMapper.updateCategory(category) > 0;
    }

    @Override
    public boolean deleteCategory(Integer id) {
        return categoryMapper.deleteCategory(id) > 0;
    }
}
